package com.esri.core.symbol.advanced;

import android.os.Environment;
import com.esri.core.geometry.SpatialReference;
import com.esri.core.internal.RuntimeHelper;
import com.esri.core.internal.symbol.advanced.MessageProcessorInternal;
import com.esri.core.map.Graphic;
import com.esri.core.symbol.advanced.SymbolDictionary;
import java.io.FileNotFoundException;

/* loaded from: classes.dex */
public class MessageProcessor {
    private static String a;
    protected static String defaultDictionaryFolder;
    private MessageProcessorInternal b;
    private SymbolDictionary c;
    private String d;
    private SymbolDictionary.DictionaryType e;

    static {
        RuntimeHelper.initialize();
        a = "/ArcGIS/SymbolDictionary";
        defaultDictionaryFolder = "/sdcard" + a;
        if (Environment.getExternalStorageState().equals("mounted")) {
            defaultDictionaryFolder = Environment.getExternalStorageDirectory().getPath() + a;
        }
    }

    public MessageProcessor(SymbolDictionary.DictionaryType dictionaryType, MessageGroupLayer messageGroupLayer) throws FileNotFoundException {
        this(dictionaryType, messageGroupLayer, defaultDictionaryFolder);
    }

    public MessageProcessor(SymbolDictionary.DictionaryType dictionaryType, MessageGroupLayer messageGroupLayer, String str) throws FileNotFoundException {
        this(dictionaryType, messageGroupLayer, str, 1.0d);
    }

    public MessageProcessor(SymbolDictionary.DictionaryType dictionaryType, MessageGroupLayer messageGroupLayer, String str, double d) throws FileNotFoundException {
        if (messageGroupLayer == null) {
            throw new IllegalArgumentException("MessageGroupLayer cannot be null");
        }
        if (messageGroupLayer.getMessageProcessor() != null) {
            throw new IllegalArgumentException("MessageGroupLayer already has the MessageProccesor bound to it");
        }
        this.b = new MessageProcessorInternal(dictionaryType.toString(), messageGroupLayer.getID(), messageGroupLayer.getAddGraphicsLayerRequestCallbackHandle(), str, d);
        this.d = str;
        this.e = dictionaryType;
    }

    public SymbolDictionary getSymbolDictionary() {
        if (this.c == null) {
            try {
                this.c = new SymbolDictionary(this.e, this.d);
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }
        return this.c;
    }

    public boolean processMessage(Message message) {
        return this.b.a(message);
    }

    public Message createMessageFrom(Graphic graphic) {
        return this.b.a(graphic);
    }

    public Message createMessageFrom(String str) {
        return this.b.a(str);
    }

    public SpatialReference getDefaultMessageSpatialReference() {
        return this.b.a();
    }

    public void setDefaultMessageSpatialReference(SpatialReference spatialReference) {
        this.b.a(spatialReference);
    }

    public SymbolDictionary.DictionaryType getDictionaryType() {
        return this.e;
    }

    public String[] getMessageTypesSupported() {
        return this.b.c();
    }

    public Graphic getGraphic(String str) {
        return this.b.b(str);
    }
}
